]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Make sure to allocate all children in allocate vfuncs
authorJonas Dreßler <verdre@v0yd.nl>
Sat, 24 Oct 2020 18:25:49 +0000 (20:25 +0200)
committerMarge Bot <marge-bot@gnome.org>
Tue, 24 Nov 2020 20:20:45 +0000 (20:20 +0000)
Clutter expects actors overriding the allocate vfunc to allocate all
mapped children of the actor, otherwise bad things happen.

So make sure we actually allocate all our visible children in our custom
allocation functions, and since we don't want to give them a real
allocation, just pass them an empty ClutterActorBox.

It would be nice if we had a way to hide children during the allocation
process where no relayout is queued like gtk allows with
gtk_widget_set_child_visible(), then we could avoid those weird empty
ClutterActorBoxes.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3098

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1481>

js/ui/search.js
js/ui/userWidget.js
js/ui/workspace.js
js/ui/workspaceThumbnail.js

index 45ef424444b642d2df0e6c00a45858bf41ccf999..dd76735cec35f4045333c8e1d42c7512cd2808e4 100644 (file)
@@ -422,10 +422,11 @@ var GridSearchResultsLayout = GObject.registerClass({
 
             const [childWidth] = child.get_preferred_width(-1);
             const [childHeight] = child.get_preferred_height(-1);
-            childBox.set_size(childWidth, childHeight);
 
-            if (childBox.x1 + childWidth > width)
-                return;
+            if (childBox.x1 + childWidth <= width)
+                childBox.set_size(childWidth, childHeight);
+            else
+                childBox.set_size(0, 0);
 
             child.allocate(childBox);
 
index 4e72779082aebd0de135170e9d8316fb0db4c35f..40bf59df9b5856cbd47e55405b6c599a0e9a5370 100644 (file)
@@ -152,17 +152,21 @@ class UserWidgetLabel extends St.Widget {
 
         let [, , natRealNameWidth] = this._realNameLabel.get_preferred_size();
 
-        if (natRealNameWidth <= availWidth)
+        let childBox = new Clutter.ActorBox();
+
+        let hiddenLabel;
+        if (natRealNameWidth <= availWidth) {
             this._currentLabel = this._realNameLabel;
-        else
+            hiddenLabel = this._userNameLabel;
+        } else {
             this._currentLabel = this._userNameLabel;
+            hiddenLabel = this._realNameLabel;
+        }
         this.label_actor = this._currentLabel;
 
-        let childBox = new Clutter.ActorBox();
-        childBox.x1 = 0;
-        childBox.y1 = 0;
-        childBox.x2 = availWidth;
-        childBox.y2 = availHeight;
+        hiddenLabel.allocate(childBox);
+
+        childBox.set_size(availWidth, availHeight);
 
         this._currentLabel.allocate(childBox);
     }
index ee7cbdc20251e031d3bebea1b11c7c2f15c8acee..ee6e198b1ea1f41a0f8a52c7316773b7f504141c 100644 (file)
@@ -630,6 +630,14 @@ var WorkspaceLayout = GObject.registerClass({
 
             if (windowInfo.currentTransition) {
                 windowInfo.currentTransition.get_interval().set_final(childBox);
+
+                // The timeline of the transition might not have been updated
+                // before this allocation cycle, so make sure the child
+                // still updates needs_allocation to FALSE.
+                // Unfortunately, this relies on the fast paths in
+                // clutter_actor_allocate(), otherwise we'd start a new
+                // transition on the child, replacing the current one.
+                child.allocate(child.allocation);
                 continue;
             }
 
index 611bccfadd37bc052830c4fd0376b8c9956ff9a1..9d7a863eeeab8a89e6ccaecbdb086833a4d3f7b9 100644 (file)
@@ -1270,6 +1270,9 @@ var ThumbnailsBox = GObject.registerClass({
         let y = box.y1;
 
         if (this._dropPlaceholderPos == -1) {
+            this._dropPlaceholder.allocate_preferred_size(
+                ...this._dropPlaceholder.get_position());
+
             Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
                 this._dropPlaceholder.hide();
             });